<template>
  <div />
</template>
<script>
import { setToken } from '@/utils/auth'
import { venueList } from '@/api'
import { parseTime } from '@/utils'
export default {
  data () {
    return {
      loading: Object,
      pagination: {
        firstQueryTime: parseTime(new Date()),
        page: 1,
        rows: 10
      }
    }
  },
  created () {
    this.loading = this.$loading({
      lock: true,
      text: 'Loading',
      spinner: 'el-icon-loading'
    })
    this.renderRoute()
  },
  methods: {
    async renderRoute () {
      // console.log('场馆name', this.$route.query.name)
      // console.log('venueId', this.$route.query.venueId)
      // console.log('shopId', this.$route.query.shopId)
      // console.log('userId', this.$route.query.userId)
      // console.log('useLogin', this.$route.query.token)
      sessionStorage.setItem('venueId', this.$route.query.venueId)
      sessionStorage.setItem('venueInfo', JSON.stringify(JSON.parse(this.$route.query.venueInfo)))
      localStorage.setItem('shopId', this.$route.query.shopId || '')
      sessionStorage.setItem('userId', this.$route.query.userId)
      sessionStorage.setItem('name', this.$route.query.name)
      sessionStorage.setItem('isLogin', true)
      setToken('useLogin', this.$route.query.token)
      await this.$store.dispatch('routes/changeRoutes')
      this.loading.close()
      this.$router.push('/home')
    },
    getVenueMessage () {
      // console.log('获取场馆信息')
      const param = {
        id: this.$route.query.userId,
        list: [this.$route.query.venueId]
      }
      const { pagination } = this
      venueList({ param, pagination, userId: this.$route.query.userId })
        .then(res => {
          // console.log('获取成功')
          if (res.recordList.length <= 1) {
            sessionStorage.setItem('venueId', res.recordList[0].id)
            sessionStorage.setItem('logo', res.recordList[0].showLogo)
            sessionStorage.setItem('name', res.recordList[0].name)
            this.renderRoute()
          }
        })
    }
  }
}
</script>
